package com.lwy.qiuchao.field.controller;

import java.util.Arrays;
import java.util.Map;


import com.lwy.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lwy.qiuchao.field.entity.FieldInfoEntity;
import com.lwy.qiuchao.field.service.FieldInfoService;
import com.lwy.common.utils.PageUtils;


/**
 * 
 *
 * @author lwy
 * @email ${email}
 * @date 2020-12-01 14:41:42
 */
@RestController
@RequestMapping("field/fieldinfo")
public class FieldInfoController {
    @Autowired
    private FieldInfoService fieldInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = fieldInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{fieldId}")

    public R info(@PathVariable("fieldId") Long fieldId){
		FieldInfoEntity fieldInfo = fieldInfoService.getById(fieldId);

        return R.ok().put("fieldInfo", fieldInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody FieldInfoEntity fieldInfo){
		fieldInfoService.save(fieldInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")

    public R update(@RequestBody FieldInfoEntity fieldInfo){
		fieldInfoService.updateById(fieldInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public R delete(@RequestBody Long[] fieldIds){
		fieldInfoService.removeByIds(Arrays.asList(fieldIds));

        return R.ok();
    }

}
